package com.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.properties.GirlPropertis;
/**
 * 
* @ClassName: HelloController 
* @Description: TODO 一个简单的控制层代码示例 
* @author 强哥 
* @date 2017年12月6日 上午9:08:38 
*@RestController 在spring4之后新加注解相当于@ResponseBoy+@Controller
 */
@RestController
@RequestMapping("hello")
public class HelloController {
	@Value("${cupSize}")
	private String cupSize;
	@Value("${age}")
	private int age;
	
	@Value("${content}")
	private String content;
	@Autowired
	private GirlPropertis girlPropertis;
	/**
	 * 
	* @Title: say 
	* @Description: TODO(rest 访问方式测试) 
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	@RequestMapping(value={"hello","hi","say"},
			/*method=RequestMethod.GET*/ method=RequestMethod.POST)
	public String say(){
//		return "Hello Spring Boot";
//		return cupSize+" "+age;
//		return content;
		return girlPropertis.getCupSize();
	}
	
	/**
	 * 
	* @Title: say1 
	* @Description: TODO(rest参数传递) 
	* @param @param id
	* @param @param myname
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	* 访问地址：http://localhost:8080/springbootdemo/hello/say/1?name=zq
	* 
	 */
//	@RequestMapping(value="/say/{id}", method=RequestMethod.POST)
//	@GetMapping(value="/say/{id}")//这个是get方式配置简化书写方式 ※推荐
	@PostMapping(value="/say/{id}")//这个是post方式配置简化书写方式※推荐
	public String say1(@PathVariable Integer id,
			@RequestParam(
					value="name",
					required=false, /*设置是否必传*/ 
					defaultValue="default zq") /*设置参数默认值*/
				String myname){
//		return "Hello Spring Boot";
//		return cupSize+" "+age;
//		return content;
		return "id:"+id+";name:"+myname;
	}
	
	
	
	
	
}
